home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
edit
/
elv18src.zip
/
opts.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-13
|
23KB
|
1,104 lines
/* opts.c */
/* Author:
* Steve Kirkendall
* 14407 SW Teal Blvd. #C
* Beaverton, OR 97005
* kirkenda@cs.pdx.edu
*/
/* modified by TJH and FEB to port to VMS */
/* This file contains the code that manages the run-time options -- The
* values that can be modified via the "set" command.
*/
#include "config.h"
#include "vi.h"
#include "ctype.h"
#include <stdio.h>
#if VMS
# include <ssdef.h>
# include <iodef.h>
# include <descrip.h>
# include <tt2def.h>
#endif
#ifndef NULL
#define NULL (char *)0
#endif
/* maximum width to permit for strings, including ="" */
#define MAXWIDTH 20
/* These are the default values of all options */
char o_autoindent[1] = {FALSE};
char o_autoprint[1] = {TRUE};
char o_autotab[1] = {TRUE};
char o_autowrite[1] = {FALSE};
char o_columns[3] = {80, 32, ~0};
char o_directory[30] = TMPDIR;
char o_edcompatible[1] = {FALSE};
char o_equalprg[80] = {"fmt"};
char o_errorbells[1] = {TRUE};
char o_exrefresh[1] = {TRUE};
char o_ignorecase[1] = {FALSE};
char o_keytime[3] = {2, 0, 50};
char o_keywordprg[80] = {KEYWORDPRG};
char o_lines[3] = {25, 2, 96};
char o_list[1] = {FALSE};
char o_number[1] = {FALSE};
char o_readonly[1] = {FALSE};
char o_remap[1] = {TRUE};
char o_report[3] = {5, 1, 127};
char o_scroll[3] = {12, 1, 127};
char o_shell[60] = SHELL;
char o_shiftwidth[3] = {8, 1, ~0};
char o_sidescroll[3] = {8, 1, 40};
char o_sync[1] = {NEEDSYNC};
char o_tabstop[3] = {8, 1, 40};
char o_term[30] = "?";
char o_flash[1] = {TRUE};
char o_warn[1] = {TRUE};
char o_wrapscan[1] = {TRUE};
#ifndef CRUNCH
char o_beautify[1] = {FALSE};
char o_exrc[1] = {FALSE};
char o_mesg[1] = {TRUE};
char o_more[1] = {TRUE};
char o_nearscroll[3] = {15, 0, ~0};
char o_newfile[1] = {FALSE};
char o_novice[1] = {FALSE};
char o_optimize[1] = {FALSE};
char o_prompt[1] = {TRUE};
char o_taglength[3] = {0, 0, 30};
char o_tags[256] = {"tags"};
char o_terse[1] = {FALSE};
char o_window[3] = {0, 0, ~0};
char o_wrapmargin[3] = {0, 0, ~0};
char o_writeany[1] = {FALSE};
#endif
#ifndef NO_ERRLIST
char o_cc[30] = {CC_COMMAND};
char o_make[30] = {MAKE_COMMAND};
#endif
#ifndef NO_CHARATTR
char o_charattr[1] = {FALSE};
#endif
#ifndef NO_DIGRAPH
char o_digraph[1] = {FALSE};
char o_flipcase[80]
# ifdef CS_IBMPC
= {"\207\200\201\232\202\220\204\216\206\217\221\222\224\231\244\245\233\235"}
# endif
# ifdef CS_LATIN1
/* initialized by initopts() */
# endif
;
#endif
#ifndef NO_SENTENCE
char o_hideformat[1] = {FALSE};
#endif
#ifndef NO_EXTENSIONS
char o_inputmode[1] = {FALSE};
char o_ruler[1] = {FALSE};
#endif
#ifndef NO_MAGIC
char o_magic[1] = {TRUE};
#endif
#ifndef NO_MODELINES
char o_modelines[1] = {FALSE};
#endif
#ifndef NO_SENTENCE
char o_paragraphs[30] = "PPppIPLPQP";
char o_sections[30] = "NHSHSSSEse";
#endif
#if MSDOS
char o_pcbios[1] = {TRUE};
char o_controlz[1] = {TRUE};
#endif
#if OS2
char o_viomode[1] = {FALSE};
#endif
#ifndef NO_SHOWMATCH
char o_showmatch[1] = {FALSE};
#endif
#ifndef NO_SHOWMODE
char o_smd[1] = {FALSE};
#endif
#ifndef NO_TAGSTACK
char o_tagstack[1] = {TRUE};
#endif
#ifdef DEBUG
char o_slowmacro[1] = {FALSE};
#endif
/* The following describes the names & types of all options */
#define BOOL 0
#define NUM 1
#define STR 2
#define SET 0x01 /* this option has had its value altered */
#define CANSET 0x02 /* this option can be set at any time */
#define RCSET 0x06 /* this option can be set in a .exrc file only */
#define NOSAVE 0x0a /* this option should never be saved by mkexrc */
#define MR 0x20 /* does this option affect the way text is displayed? */
struct
{
char *name; /* name of an option */
char *nm; /* short name of an option */
char type; /* type of an option */
char flags; /* boolean: has this option been set? */
char *value; /* value */
}
opts[] =
{
/* name type flags value */
{ "autoindent", "ai", BOOL, CANSET, o_autoindent },
{ "autoprint", "ap", BOOL, CANSET, o_autoprint },
{ "autotab", "at", BOOL, CANSET, o_autotab },
{ "autowrite", "aw", BOOL, CANSET, o_autowrite },
#ifndef CRUNCH
{ "beautify", "bf", BOOL, CANSET, o_beautify },
#endif
#ifndef NO_ERRLIST
{ "cc", "cc", STR, CANSET, o_cc },
#endif
#ifndef NO_CHARATTR
{ "charattr", "ca", BOOL, CANSET|MR, o_charattr },
#endif
{ "columns", "co", NUM, SET|NOSAVE|MR, o_columns },
#if MSDOS
{ "controlz", "z", BOOL, CANSET, o_controlz },
#endif
#ifndef NO_DIGRAPH
{ "digraph", "dig", BOOL, CANSET, o_digraph },
#endif
{ "directory", "dir", STR, RCSET, o_directory },
{ "edcompatible","ed", BOOL, CANSET, o_edcompatible },
{ "equalprg", "ep", STR, CANSET, o_equalprg },
{ "errorbells", "eb", BOOL, CANSET, o_errorbells },
#ifndef CRUNCH
{ "exrc", "exrc", BOOL, CANSET, o_exrc },
#endif
{ "exrefresh", "er", BOOL, CANSET, o_exrefresh },
{ "flash", "vbell",BOOL, CANSET, o_flash },
#ifndef NO_DIGRAPH
{ "flipcase", "fc", STR, CANSET, o_flipcase },
#endif
#ifndef NO_SENTENCE
{ "hideformat", "hf", BOOL, CANSET|MR, o_hideformat },
#endif
{ "ignorecase", "ic", BOOL, CANSET, o_ignorecase },
#ifndef NO_EXTENSIONS
{ "inputmode", "im", BOOL, CANSET, o_inputmode },
#endif
{ "keytime", "kt", NUM, CANSET, o_keytime },
{ "keywordprg", "kp", STR, CANSET, o_keywordprg },
{ "lines", "ls", NUM, SET|NOSAVE|MR, o_lines },
{ "list", "li", BOOL, CANSET|MR, o_list },
#ifndef NO_MAGIC
{ "magic", "ma", BOOL, CANSET, o_magic },
#endif
#ifndef NO_ERRLIST
{ "make", "mk", STR, CANSET, o_make },
#endif
#ifndef CRUNCH
{ "mesg", "me", BOOL, CANSET, o_mesg },
#endif
#ifndef NO_MODELINES
{ "modelines", "ml", BOOL, CANSET, o_modelines },
#endif
#ifndef CRUNCH
{ "more", "mo", BOOL, CANSET, o_more },
{ "nearscroll", "ns", NUM, CANSET, o_nearscroll },
{ "newfile", "new", BOOL, NOSAVE, o_newfile },
{ "novice", "nov", BOOL, CANSET, o_novice },
#endif
{ "number", "nu", BOOL, CANSET|MR, o_number },
#ifndef CRUNCH
{ "optimize", "opt", BOOL, CANSET, o_optimize },
#endif
#ifndef NO_SENTENCE
{ "paragraphs", "para", STR, CANSET, o_paragraphs },
#endif
#if MSDOS
{ "pcbios", "pc", BOOL, SET|NOSAVE, o_pcbios },
#endif
#ifndef CRUNCH
{ "prompt", "pr", BOOL, CANSET, o_prompt },
#endif
{ "readonly", "ro", BOOL, CANSET, o_readonly },
{ "remap", "remap",BOOL, CANSET, o_remap },
{ "report", "re", NUM, CANSET, o_report },
#ifndef NO_EXTENSIONS
{ "ruler", "ru", BOOL, CANSET, o_ruler },
#endif
{ "scroll", "sc", NUM, CANSET, o_scroll },
#ifndef NO_SENTENCE
{ "sections", "sect", STR, CANSET, o_sections },
#endif
{ "shell", "sh", STR, CANSET, o_shell },
#ifndef NO_SHOWMATCH
{ "showmatch", "sm", BOOL, CANSET, o_showmatch },
#endif
#ifndef NO_SHOWMODE
{ "showmode", "smd", BOOL, CANSET, o_smd },
#endif
{ "shiftwidth", "sw", NUM, CANSET, o_shiftwidth },
{ "sidescroll", "ss", NUM, CANSET, o_sidescroll },
#ifdef DEBUG
{ "slowmacro", "slow", BOOL, CANSET, o_slowmacro },
#endif
{ "sync", "sy", BOOL, CANSET, o_sync },
{ "tabstop", "ts", NUM, CANSET|MR, o_tabstop },
#ifndef CRUNCH
{ "taglength", "tl", NUM, CANSET, o_taglength },
{ "tags", "tag", STR, CANSET, o_tags },
#endif
#ifndef NO_TAGSTACK
{ "tagstack", "tgs", BOOL, CANSET, o_tagstack },
#endif
{ "term", "te", STR, SET, o_term },
#ifndef CRUNCH
{ "terse", "tr", BOOL, CANSET, o_terse },
{ "timeout", "to", BOOL, CANSET, o_keytime },
#endif
#if OS2
{ "viomode", "vm", BOOL, CANSET|MR, o_viomode },
#endif
{ "warn", "wa", BOOL, CANSET, o_warn },
#ifndef CRUNCH
{ "window", "wi", NUM, CANSET|MR, o_window },
{ "wrapmargin", "wm", NUM, CANSET, o_wrapmargin },
#endif
{ "wrapscan", "ws", BOOL, CANSET, o_wrapscan },
#ifndef CRUNCH
{ "writeany", "wr", BOOL, CANSET, o_writeany },
#endif
{ NULL, NULL, 0, CANSET, NULL }
};
/* This function initializes certain options from environment variables, etc. */
void initopts()
{
char *val;
int i;
#if VMS
int tty_ichan;
char chbuf[12];
$DESCRIPTOR(inpdev,"TT");
int err;
struct terminfo {
unsigned class:8;
unsigned type:8;
unsigned pwidth:16;
unsigned tchar:22;
unsigned dummy:2;
unsigned plength:8;
unsigned xchar:32;
} tinfo;
struct iostab {
short int status;
short int terminator_offset;
short int terminator;
short int terminator_size;
} iostab;
#endif